package com.qf.service.impl;

import com.qf.dao.BookDao;
import com.qf.dao.impl.BookDaoImpl;
import com.qf.entity.Book;
import com.qf.entity.Page;
import com.qf.service.BookService;

import java.util.List;

/**
 * @author 孙亚梅
 * @version V1.0
 * @Project bookApp-homework
 * @Package com.qf.service.impl
 * @Description:
 * @Date 2022/5/14 19:18
 */
public class BookServiceImpl implements BookService {
    private BookDao bookDao = new BookDaoImpl();

    @Override
    public List<Book> getAll() {
        return bookDao.selectAll();
    }

    @Override
    public boolean addBook(Book book) {
        return bookDao.addOne(book)>0;
    }

    @Override
    public boolean deleteBook(String bookId) {
        return bookDao.deleteOne(bookId)>0;
    }

    @Override
    public Book getBook(String bookId) {
        return bookDao.selectOne(bookId);
    }

    @Override
    public boolean updateBook(Book book) {
        return bookDao.updateOne(book)>0;
    }

    @Override
    public List<Book> findAllPage(Page page) {
         List<Book> list = bookDao.selectAllByPage(page);
         return  list;
    }

    @Override
    public int finAllPageCount() {
       int count=bookDao.selectAllByPageCount();
        return count;
    }

}
